import os.path

import pytest
from conf import settings

TOKEN = None


@pytest.fixture(scope="session", autouse=True)
def token_fixture():
    global TOKEN
    # TOKEN = requests.post(url="", data="", headers={}).json()["data"]["token"]
    TOKEN = "app token......"
    yield


@pytest.fixture(scope="session", autouse=True)
def log_fixture():
    if not os.path.exists(settings.LOG_DIR):
        os.mkdir(settings.LOG_DIR)
    f = open(settings.INFO_LOG_PATH, "w", encoding="utf8")
    f.close()
    f = open(settings.ERROR_LOG_PATH, "w", encoding="utf8")
    f.close()
    yield


# @pytest.fixture(scope="session", autouse=True)
# def ding_fixture():
#     yield
#     ap = AllureReport()
#     DingTalk().send_text(
#         f"测试已完成，点此查看测试报告"
#         f"http://{settings.ALLURE_HOST}:{settings.ALLURE_PORT}/index.html#\n"
#         f"通过：  {ap.passed_count}\n"
#         f"失败：  {ap.failed_count}\n"
#         f"异常：  {ap.broken_count}\n"
#         f"跳过：  {ap.skipped_count}\n"
#         f"总计：  {ap.total_count}\n"
#         f"通过率：{ap.pass_rate} %\n"
#         f"执行总时长：{ap.process_duration} 秒")
